Test Series - Data Structure

Test Number 113/115

Q: What is the number of unlabeled simple directed graph that can be made with 1 or 2 vertices?
A. 2
B. 4
C. 5
D. 9
Solution: no solution
Q: Floyd Warshall Algorithm used to solve the shortest path problem has a time complexity of __________
A. O(V*V)
B. O(V*V*V)
C. O(E*V)
D. O(E*E)
Solution: The Algorithm uses Dynamic Programming and checks for every possible path.
Q: All Graphs have unique representation on paper.
A. True
B. False
C. ...
D. ...
Solution: Same Graph may be drawn in different ways on paper.
Q: Assuming value of every weight to be greater than 10, in which of the following cases the shortest path of a directed weighted graph from 2 vertices u and v will never change?
A. add all values by 10
B. subtract 10 from all the values
C. multiply all values by 10
D. in both the cases of multiplying and adding by 10
Solution: In case of addition or subtraction the shortest path may change because the number of edges between different paths may be different, while in case of multiplication path wont change.
Q: What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?
A. 28
B. 64
C. 256
D. 56
Solution: If a graph has V vertices than every vertex can be connected to a possible of V-1 vertices.
Q: What would be the value of the distance matrix, after the execution of the given code?

#include 
#define INF 1000000
int graph[V][V] = {   {0,   7,  INF, 4},
                      {INF, 0,   13, INF},
                      {INF, INF, 0,   12},
                      {INF, INF, INF, 0}
                  };
 
int distance[V][V], i, j, k;
 
for (i = 0; i < V; i++)
        for (j = 0; j < V; j++)
    	distance[i][j] = graph[i][j];
 
for (k = 0; k < V; k++)
	for (i = 0; i < V; i++)
        	for (j = 0; j < V; j++)
                {
            		if (distance[i][k] + distance[k][j] < distance[i][j])
                		distance[i][j] = distance[i][k] + distance[k][j];
 
                           return 0;
                }
A. { {0, 7, INF, 4}, {INF, 0, 13, INF}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };
B. { {0, 7, 20, 24}, {INF, 0, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} };
C. { {0, INF, 20, 24}, {INF, INF, 13, 25}, {INF, INF, 0, 12}, {INF, INF, INF, 0} {INF, 0, 13, 25}, {INF, INF, 0, 12}, {24, INF, INF, 0} };
D. None of the mentioned
Solution: The program computes the shortest sub distances.
Q: What is the maximum number of edges present in a simple directed graph with 7 vertices if there exists no cycles in the graph?
A. 21
B. 7
C. 6
D. 49
Solution: If the no cycles exists then the difference between the number of vertices and edges is 1.
Q: With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph possess?
A. (V*(V-1))/2
B. (V*(V+1))/2
C. (V+1)C2
D. (V-1)C2
Solution: The first edge would have an outgoing degree of atmost V-1, the next edge would have V-2 and so on, hence V-1 + V-2…. +1 equals (V*(V-1))/2.

You Have Score    /8